package com.example.shop_car_2208.adapter

import android.widget.ImageView
import com.bumptech.glide.Glide
import com.chad.library.adapter.base.BaseMultiItemQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.example.shop_car_2208.R
import com.example.shop_car_2208.entity.CommentEntity
import com.example.shop_car_2208.utils.GlideUtils

class CommentAdapter:BaseMultiItemQuickAdapter<CommentEntity,BaseViewHolder>() {
    init {
        addItemType(0, R.layout.item_comment_one)
        addItemType(1,R.layout.item_comment_two)
        addItemType(2,R.layout.item_comment_three)
    }
    override fun convert(holder: BaseViewHolder, item: CommentEntity) {
        when(holder.itemViewType ){
            0->{
                holder.setText(R.id.comment_name,item.username)
                holder.setText(R.id.comment_count,item.msg)
                holder.setText(R.id.comment_time,item.createtime)
                val view = holder.getView<ImageView>(R.id.comment_icon)
                Glide.with(context).load(item.icon).circleCrop().into(view)
            }
            2->{
                holder.setText(R.id.comment_name,item.username)
                holder.setText(R.id.comment_count,item.msg)
                holder.setText(R.id.comment_time,item.createtime)
                val view = holder.getView<ImageView>(R.id.comment_icon)
                Glide.with(context).load(item.icon).circleCrop().into(view)
                holder.setText(R.id.tousername,"${item.username}")
            }
        }
    }
}